﻿using System;
using System.Collections.Generic;
using IllusionUtility.SetUtility;
using UnityEngine;

// Token: 0x02000257 RID: 599
public abstract class CharClothes
{
	// Token: 0x06000DE9 RID: 3561 RVA: 0x00062874 File Offset: 0x00060A74
	public CharClothes(global::CharInfo info)
	{
		this.chaInfo = info;
		this.chaFile = this.chaInfo.chaFile;
		this.clothesInfo = this.chaInfo.clothesInfo;
		this.statusInfo = this.chaInfo.statusInfo;
		this.dictStateType = new Dictionary<int, Dictionary<byte, string>>();
		this.dictStateType.Clear();
	}

	// Token: 0x170001E7 RID: 487
	// (get) Token: 0x06000DEA RID: 3562 RVA: 0x000628D8 File Offset: 0x00060AD8
	// (set) Token: 0x06000DEB RID: 3563 RVA: 0x000628E0 File Offset: 0x00060AE0
	public Dictionary<int, Dictionary<byte, string>> dictStateType { get; set; }

	// Token: 0x06000DEC RID: 3564
	public abstract bool AddStateKind(int clothKind, string stateType);

	// Token: 0x06000DED RID: 3565
	public abstract void RemoveStateKind(int clothKind);

	// Token: 0x06000DEE RID: 3566 RVA: 0x000628EC File Offset: 0x00060AEC
	public bool IsStateKind(int stateKind)
	{
		return this.dictStateType.ContainsKey(stateKind);
	}

	// Token: 0x06000DEF RID: 3567 RVA: 0x000628FC File Offset: 0x00060AFC
	public Dictionary<byte, string> GetStateKind(int stateKind)
	{
		Dictionary<byte, string> result = null;
		this.dictStateType.TryGetValue(stateKind, out result);
		return result;
	}

	// Token: 0x06000DF0 RID: 3568 RVA: 0x0006291C File Offset: 0x00060B1C
	public bool IsStateType(int stateKind, byte stateType)
	{
		Dictionary<byte, string> dictionary = null;
		this.dictStateType.TryGetValue(stateKind, out dictionary);
		return dictionary != null && dictionary.ContainsKey(stateType);
	}

	// Token: 0x06000DF1 RID: 3569 RVA: 0x0006294C File Offset: 0x00060B4C
	public bool IsAccessory(int slotNo)
	{
		return global::MathfEx.RangeEqualOn(0, slotNo, 9) && !(null == this.chaInfo.chaBody.objAccessory[slotNo]);
	}

	// Token: 0x06000DF2 RID: 3570
	public abstract void SetClothesState(int clothesStateKind, byte state);

	// Token: 0x06000DF3 RID: 3571 RVA: 0x00062984 File Offset: 0x00060B84
	public void SetClothesStateNext(int clothesStateKind)
	{
		int b = this.statusInfo.clothesState[clothesStateKind];
		b = (b + 1) % 3;
		this.SetClothesState(clothesStateKind, (byte)b);
	}

	// Token: 0x06000DF4 RID: 3572
	public abstract void SetClothesStateAll(byte state);

	// Token: 0x06000DF5 RID: 3573
	public abstract void UpdateClothesStateAll();

	// Token: 0x06000DF6 RID: 3574 RVA: 0x000629B0 File Offset: 0x00060BB0
	public void SetAccessoryStateAll(bool show)
	{
		for (int i = 0; i < this.statusInfo.showAccessory.Length; i++)
		{
			this.statusInfo.showAccessory[i] = show;
		}
	}

	// Token: 0x06000DF7 RID: 3575 RVA: 0x000629EC File Offset: 0x00060BEC
	public string GetAccessoryDefaultParentStr(int type, int id)
	{
		int num = Enum.GetNames(typeof(global::CharaListInfo.TypeAccessoryFbx)).Length;
		if (!global::MathfEx.RangeEqualOn(0, type, num - 1))
		{
			return string.Empty;
		}
		global::ListTypeFbx listTypeFbx = null;
		Dictionary<int, global::ListTypeFbx> accessoryFbxList = this.chaInfo.ListInfo.GetAccessoryFbxList((global::CharaListInfo.TypeAccessoryFbx)type, true);
		if (!accessoryFbxList.TryGetValue(id, out listTypeFbx))
		{
			return string.Empty;
		}
		return listTypeFbx.Parent;
	}

	// Token: 0x06000DF8 RID: 3576 RVA: 0x00062A54 File Offset: 0x00060C54
	public string GetAccessoryDefaultParentStr(int slotNo)
	{
		GameObject gameObject = this.chaInfo.chaBody.objAccessory[slotNo];
		if (null == gameObject)
		{
			return string.Empty;
		}
		global::ListTypeFbxComponent component = gameObject.GetComponent<global::ListTypeFbxComponent>();
		return component.ltfData.Parent;
	}

	// Token: 0x06000DF9 RID: 3577 RVA: 0x00062A98 File Offset: 0x00060C98
	public bool ChangeAccessoryParent(int slotNo, string parentStr)
	{
		if (!global::MathfEx.RangeEqualOn(0, slotNo, 9))
		{
			return false;
		}
		GameObject gameObject = this.chaInfo.chaBody.objAccessory[slotNo];
		if (null == gameObject)
		{
			return false;
		}
		global::ListTypeFbxComponent component = gameObject.GetComponent<global::ListTypeFbxComponent>();
		global::ListTypeFbx ltfData = component.ltfData;
		if ("0" == ltfData.Parent)
		{
			return false;
		}
		try
		{
			global::CharReference.RefObjKey key = (global::CharReference.RefObjKey)((int)Enum.Parse(typeof(global::CharReference.RefObjKey), parentStr));
			GameObject referenceInfo = this.chaInfo.GetReferenceInfo(key);
			if (null == referenceInfo)
			{
				return false;
			}
			gameObject.transform.SetParent(referenceInfo.transform, false);
			this.clothesInfo.accessory[slotNo].parentKey = parentStr;
		}
		catch (ArgumentException)
		{
			return false;
		}
		return true;
	}

	// Token: 0x06000DFA RID: 3578 RVA: 0x00062B84 File Offset: 0x00060D84
	public bool SetAccessoryPos(int slotNo, float value, bool _add, int flags = 7)
	{
		if (!global::MathfEx.RangeEqualOn(0, slotNo, 9))
		{
			return false;
		}
		GameObject gameObject = this.chaInfo.chaBody.objAcsMove[slotNo];
		if (null == gameObject)
		{
			return false;
		}
		if ((flags & 1) != 0)
		{
			float value2 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addPos.x) + value;
			this.clothesInfo.accessory[slotNo].addPos.x = Mathf.Clamp(value2, -1f, 1f);
		}
		if ((flags & 2) != 0)
		{
			float value3 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addPos.y) + value;
			this.clothesInfo.accessory[slotNo].addPos.y = Mathf.Clamp(value3, -1f, 1f);
		}
		if ((flags & 4) != 0)
		{
			float value4 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addPos.z) + value;
			this.clothesInfo.accessory[slotNo].addPos.z = Mathf.Clamp(value4, -1f, 1f);
		}
		gameObject.transform.SetLocalPosition(this.clothesInfo.accessory[slotNo].addPos.x, this.clothesInfo.accessory[slotNo].addPos.y, this.clothesInfo.accessory[slotNo].addPos.z);
		return true;
	}

	// Token: 0x06000DFB RID: 3579 RVA: 0x00062D24 File Offset: 0x00060F24
	public bool SetAccessoryRot(int slotNo, float value, bool _add, int flags = 7)
	{
		if (!global::MathfEx.RangeEqualOn(0, slotNo, 9))
		{
			return false;
		}
		GameObject gameObject = this.chaInfo.chaBody.objAcsMove[slotNo];
		if (null == gameObject)
		{
			return false;
		}
		if ((flags & 1) != 0)
		{
			float t = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addRot.x) + value;
			this.clothesInfo.accessory[slotNo].addRot.x = Mathf.Repeat(t, 360f);
		}
		if ((flags & 2) != 0)
		{
			float t2 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addRot.y) + value;
			this.clothesInfo.accessory[slotNo].addRot.y = Mathf.Repeat(t2, 360f);
		}
		if ((flags & 4) != 0)
		{
			float t3 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addRot.z) + value;
			this.clothesInfo.accessory[slotNo].addRot.z = Mathf.Repeat(t3, 360f);
		}
		gameObject.transform.SetLocalRotation(this.clothesInfo.accessory[slotNo].addRot.x, this.clothesInfo.accessory[slotNo].addRot.y, this.clothesInfo.accessory[slotNo].addRot.z);
		return true;
	}

	// Token: 0x06000DFC RID: 3580 RVA: 0x00062EB4 File Offset: 0x000610B4
	public bool SetAccessoryScl(int slotNo, float value, bool _add, int flags = 7)
	{
		if (!global::MathfEx.RangeEqualOn(0, slotNo, 9))
		{
			return false;
		}
		GameObject gameObject = this.chaInfo.chaBody.objAcsMove[slotNo];
		if (null == gameObject)
		{
			return false;
		}
		if ((flags & 1) != 0)
		{
			float value2 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addScl.x) + value;
			this.clothesInfo.accessory[slotNo].addScl.x = Mathf.Clamp(value2, 0.01f, 100f);
		}
		if ((flags & 2) != 0)
		{
			float value3 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addScl.y) + value;
			this.clothesInfo.accessory[slotNo].addScl.y = Mathf.Clamp(value3, 0.01f, 100f);
		}
		if ((flags & 4) != 0)
		{
			float value4 = ((!_add) ? 0f : this.clothesInfo.accessory[slotNo].addScl.z) + value;
			this.clothesInfo.accessory[slotNo].addScl.z = Mathf.Clamp(value4, 0.01f, 100f);
		}
		gameObject.transform.SetLocalScale(this.clothesInfo.accessory[slotNo].addScl.x, this.clothesInfo.accessory[slotNo].addScl.y, this.clothesInfo.accessory[slotNo].addScl.z);
		return true;
	}

	// Token: 0x06000DFD RID: 3581 RVA: 0x00063054 File Offset: 0x00061254
	public bool ResetAccessoryMove(int slotNo, int type = 7)
	{
		bool flag = true;
		if ((type & 1) != 0)
		{
			flag &= this.SetAccessoryPos(slotNo, 0f, false, 7);
		}
		if ((type & 2) != 0)
		{
			flag &= this.SetAccessoryRot(slotNo, 0f, false, 7);
		}
		if ((type & 4) != 0)
		{
			flag &= this.SetAccessoryScl(slotNo, 1f, false, 7);
		}
		return flag;
	}

	// Token: 0x06000DFE RID: 3582 RVA: 0x000630B0 File Offset: 0x000612B0
	public bool UpdateAccessoryMoveFromInfo(int slotNo)
	{
		if (!global::MathfEx.RangeEqualOn(0, slotNo, 9))
		{
			return false;
		}
		GameObject gameObject = this.chaInfo.chaBody.objAcsMove[slotNo];
		if (null == gameObject)
		{
			return false;
		}
		gameObject.transform.SetLocalPosition(this.clothesInfo.accessory[slotNo].addPos.x, this.clothesInfo.accessory[slotNo].addPos.y, this.clothesInfo.accessory[slotNo].addPos.z);
		gameObject.transform.SetLocalRotation(this.clothesInfo.accessory[slotNo].addRot.x, this.clothesInfo.accessory[slotNo].addRot.y, this.clothesInfo.accessory[slotNo].addRot.z);
		gameObject.transform.SetLocalScale(this.clothesInfo.accessory[slotNo].addScl.x, this.clothesInfo.accessory[slotNo].addScl.y, this.clothesInfo.accessory[slotNo].addScl.z);
		return true;
	}

	// Token: 0x06000DFF RID: 3583 RVA: 0x000631E0 File Offset: 0x000613E0
	public void UpdateAccessoryMoveAllFromInfo()
	{
		for (int i = 0; i < 10; i++)
		{
			this.UpdateAccessoryMoveFromInfo(i);
		}
	}

	// Token: 0x06000E00 RID: 3584 RVA: 0x00063208 File Offset: 0x00061408
	public bool ChangeAccessoryColor(int slotNo)
	{
		if (!global::MathfEx.RangeEqualOn(0, slotNo, 9))
		{
			return false;
		}
		global::CharReference.TagObjKey[] array = new global::CharReference.TagObjKey[]
		{
			global::CharReference.TagObjKey.ObjASlot01,
			global::CharReference.TagObjKey.ObjASlot02,
			global::CharReference.TagObjKey.ObjASlot03,
			global::CharReference.TagObjKey.ObjASlot04,
			global::CharReference.TagObjKey.ObjASlot05,
			global::CharReference.TagObjKey.ObjASlot06,
			global::CharReference.TagObjKey.ObjASlot07,
			global::CharReference.TagObjKey.ObjASlot08,
			global::CharReference.TagObjKey.ObjASlot09,
			global::CharReference.TagObjKey.ObjASlot10
		};
		List<GameObject> tagInfo = this.chaInfo.GetTagInfo(array[slotNo]);
		global::ColorChange.SetHSColor(tagInfo, this.clothesInfo.accessory[slotNo].color, true, true, this.clothesInfo.accessory[slotNo].color2, true, true);
		return true;
	}

	// Token: 0x04000F01 RID: 3841
	public global::CharInfo chaInfo;

	// Token: 0x04000F02 RID: 3842
	public global::CharFile chaFile;

	// Token: 0x04000F03 RID: 3843
	public global::CharFileInfoClothes clothesInfo;

	// Token: 0x04000F04 RID: 3844
	public global::CharFileInfoStatus statusInfo;
}
